Number.prototype.formatMoney = function(c, d, t){ var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "." : d, t = t == undefined ? "," : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0; var r = s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); r += ''; r = r.replace('.00', ''); return r; }; if (!String.prototype.format) { String.prototype.format = function () { var args = arguments; return this.replace(/{(\d+)}/g, function (match, number) { if (args[0] !== undefined && args[0].constructor === Array) { return typeof args[0][number] != 'undefined' ? args[0][number] : match; } else { return typeof args[number] != 'undefined' ? args[number] : match; } }); }; } var debugMode = false; var marginTop1 = 0; var marginTop2 = 0; var marginTop3 = 0; if(bowser.name == 'Firefox') { marginTop1 = 4; marginTop2 = 4; marginTop3 = 2; } function consoleLog(logMessage) { if (debugMode) console.log(logMessage); } var keys_short = []; var keys_long = []; function RenameObjectKeys(o) { /* var build, key, destKey, ix, value; if(o.constructor === Array) { build = new Array(); } else { build = {}; } for (key in o) { ix = keys_short.indexOf(key); destKey = ix === -1 ? key : keys_long[ix]; value = o[key]; if (value !== null && typeof value === "object") { value = RenameObjectKeys(value); } build[destKey] = value; } return build; */ return o; } function GetParameterByName(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(location.search); return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } function FindIndexByKeyValue(obj, key, value) { for (var i = 0; i < obj.length; i++) { if (obj[i][key] == value) { return i; } } return null; } function GetRandom(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } function RoundNumber(number) { return (Math.floor(parseFloat(number) * 100) / 100).toFixed(2); } function balanceToInt(balance) { var balanceString = balance + ''; var PointIndex = -1; var balanceLength = balanceString.length; var Newbalance = ''; var AfterPoint = 0; for(var i = 0; i < balanceLength; i++) { if(balanceString[i] == '.') { PointIndex = i; } else { if(PointIndex != -1) { AfterPoint++; } if(AfterPoint > 2) { } else { Newbalance += balanceString[i]; } } } if(PointIndex == -1) { Newbalance += '00'; } else { if(balanceLength - PointIndex - 1 < 2) Newbalance += '0'; } balance = parseInt(Newbalance); return balance; } Number.prototype.formatMoney = function (c, d, t) { var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "." : d, t = t == undefined ? "," : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0; var r = s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); r += ''; r = r.replace('.00', ''); return r; }; $(document).ready(function (e) { ScaleDiv(); $('#internet-lost-poup .internet-lost-loader-text').html(100); $('#connection-lost-poup .internet-lost-loader-text').html(100); $(document).on('click', '.popup-close', function() { $('.popup-div').removeClass('history-popup').fadeOut(100); }); }); $(window).resize(function () { ScaleDiv(); }); var IsObserver = false; var game_scale = 1; function ScaleDiv() { if(typeof gameInfo !== 'undefined' && gameInfo.allowHeader) { ScaleDivNew(); return; } var width = $(window).width(); var height = $(window).height(); var headerHeight = 0; if(mobileDevice) { var o_width = 1280; var o_height = 720; var o_letf = -640; if (GameName === 'Balloon') { o_width = 540; o_height = 960; o_letf = -270; } var r_deg = 0; if (GameName === 'Balloon') { if (width > height) { var width = $(window).height(); var height = $(window).width(); r_deg = -90; } } else { if(width < height) { var width = $(window).height(); var height = $(window).width(); r_deg = 90; } } } else { headerHeight = 40; if(GameName === 'Cappadocia' || GameName === 'Balloon') headerHeight = $('.game-head').is(':visible') ? $('.game-head').height() : 0; var o_width = $('.game').width(); //1239; var o_height = $('.game').height(); //746; } height -= headerHeight; var w_scale = 0; var h_scale = 0; var m_scale = 0; w_scale = width / o_width; h_scale = height / o_height; m_scale = Math.min(w_scale, h_scale); game_scale = m_scale; if (GameName === 'Balloon') { let max_scale = Math.min(w_scale, h_scale); $('#ErrorMessage').css({ 'transform': 'scale(' + max_scale + ',' + max_scale + ') rotate(' + r_deg + 'deg)'}); $('.ErrorMessage').css({ 'transform': 'scale(' + max_scale + ',' + max_scale + ') rotate(' + r_deg + 'deg)' }); $('.NetworkPopUp').css({ 'transform': 'scale(' + max_scale + ',' + max_scale + ') rotate(' + r_deg + 'deg)' }); $('.TimeOut').css({ 'transform': 'scale(' + max_scale + ',' + max_scale + ') rotate(' + r_deg + 'deg)' }); } if (m_scale < 1) { //game_scale = m_scale; } game_scale = parseFloat(game_scale); game_scale = game_scale.toFixed(2); //TODO: Add for scale if ((GameName === 'SpaceLotto' || GameName === 'DragRace') && game_scale > 1 && !mobileDevice) { game_scale = 1; } UpdateGameScale(game_scale); //JokerPoker.InitBoard(); var left = (width / game_scale - o_width) / 2; var bottom = (height / game_scale - o_height); var o_width_half = o_width / 2; if(mobileDevice) { $('.game-div').css({ 'transform': 'scale(' + game_scale + ',' + game_scale + ') rotate(' + r_deg + 'deg)', 'left': (r_deg == 90 ? '100%' : '0px'), 'top': (r_deg == -90 ? '100%' : '0px') }); $('.game').css({ 'margin-left': o_letf + 'px', 'left': (width / 2) / game_scale, 'top': '0px', 'margin-top': '0px' }); if(GameName === 'Cappadocia') { } else { $('.error-popup').css({'width': width / game_scale, 'height': height / game_scale}); //$('.error-popup-bg').css({ 'left': (width / 2) / game_scale }); $('.error-popup-bg').css({ 'transform': 'scale(' + game_scale + ',' + game_scale + ') rotate(' + r_deg + 'deg)', 'left': (width / 2) / game_scale }); } $('.popup-bg').css({ 'width': width / game_scale, 'height': height / game_scale }); $('.popup').css({ 'left': (width / 2) / game_scale }); } else { $('.game-div').css({'-ms-transform': 'scale(' + game_scale + ',' + game_scale + ')', '-webkit-transform': 'scale(' + game_scale + ',' + game_scale + ')', 'transform': 'scale(' + game_scale + ',' + game_scale + ')'}); $('.game').css({ 'margin-left': '-619.5px', 'left': (width / 2) / game_scale }); $('.content-div').css({'transform': 'scale(' + game_scale + ',' + game_scale + ')'}); $('.content').css({ 'margin-left': '-668px', 'left': (width / 2) / game_scale }); } } function ScaleDivNew() { // debugger let minWidth = 2170; let maxWidth = 2470; let minHeight = 1154; let maxHeight = 1220; const gameDiv = document.querySelector('.game-div'); const gameContent = document.getElementById('game'); let containerWidth = minWidth; let containerHeight = minHeight; let windowWidth = window.innerWidth; let windowHeight = window.innerHeight; if(mobileDevice) { maxHeight = gameInfo.vertical.maxHeight; containerHeight = gameInfo.vertical.height; maxWidth = gameInfo.vertical.maxWidth; containerWidth = gameInfo.vertical.minWidth; } const scaleX = windowWidth / containerWidth; const scaleY = windowHeight / containerHeight; const scale = Math.min(scaleX, scaleY); gameDiv.style.transform = `scale(${scale})`; let windowWidthOriginal = windowWidth; windowWidth = windowWidth / scale > maxWidth ? maxWidth * scale : windowWidth; windowHeight = windowHeight / scale > maxHeight ? maxHeight * scale : windowHeight; const left = (windowWidthOriginal / 2) / scale; const marginLeft = (containerWidth / 2) + (windowWidth / scale - containerWidth) / 2; let gameWidth = Math.max(containerWidth, windowWidth / scale); let gameHeight = Math.max(containerHeight, windowHeight / scale); gameInfo.paddingLeft = Math.max(0, gameWidth - containerWidth); gameInfo.paddingBottom = Math.max(0, gameHeight - containerHeight); try { window.parent.postMessage({ name: (GameName ? GameName.toLowerCase() : '') + "-main-width", scale : scale, maxWidth: gameWidth, mainWidth: windowWidthOriginal, marginLeft: marginLeft, position: { left: gameInfo.paddingLeft, top: gameInfo.paddingBottom}, gamePosition: $('#game').offset() }, "*") } catch(error) { } if(mobileDevice) { if (typeof canvasApp !== "undefined") { canvasApp.view.style.width = gameWidth + "px"; canvasApp.view.style.height = gameHeight + "px"; canvasApp.renderer.resize(gameWidth, gameHeight); canvasApp.stage.x = gameInfo.paddingLeft / 2; } $('.game-div').css({'width': gameWidth, 'height': gameHeight}); $('.game').css({ 'width': gameWidth, 'height': gameHeight, 'margin-left': '-' + (containerWidth / 2 + marginLeft) + 'px', 'left': (windowWidthOriginal / 2) / scale }); $('#game').css({'margin-left': '-' + (marginLeft) + 'px'}); setMobilePositions(); return; } gameContent.style.height = `${gameHeight}px`; gameContent.style.width = `${gameWidth}px`; gameContent.style.marginLeft = `${'-' + marginLeft}px`; gameContent.style.left = `${left}px`; if (typeof canvasApp !== "undefined") { canvasApp.view.style.width = windowWidth / scale + "px"; canvasApp.view.style.height = windowHeight / scale + "px"; canvasApp.renderer.resize(windowWidth / scale, windowHeight / scale); canvasApp.stage.x = gameInfo.paddingLeft / 2; } } function setMobilePositions() { } function SpriteInfo(spriteWidth, spriteHeigth, backgroundLeft, backgroundTop, positionLeft, positionTop, scale) { this.width = spriteWidth; this.height = spriteHeigth; this.backgroundLeft = backgroundLeft; this.backgroundTop = backgroundTop; this.positionLeft = positionLeft; this.positionTop = positionTop; this.scale = scale; } function LoadGameData(data, selectedOption) { } function UpdateGameScale(scale) { } function UpdateGameSound(sound) { }